package cn.edu.scau.cmi.zengdefeng.Composite;

import java.util.Set;

public class ConsistentLeaf extends ConsistentComponent{
	
	public ConsistentLeaf(ConsistentComponent parent,String name) {
		super(parent, name);
	}
	
	@Override
	public void addChild(ConsistentComponent child) {
		System.out.println("对不起，该节点时叶节点，不能添加子节点");
		
	}
	
	@Override
	public void deleteChild(ConsistentComponent child) {
		System.out.println("对不起，该节点时叶节点，不能添加子节点");
		
	};


	@Override
	public Set<ConsistentComponent> getChildren() {
		System.out.println("对不起，该节点是叶节点，没有子节点");
		return null;
	}
	@Override
	public void setChildren(Set<ConsistentComponent> children) {
		System.out.println("对不起，该节点时叶节点，不能添加子节点");
		
	}
	@Override
	public String toString() {
		return toString(1);
	}
	@Override
	String toString(int cent) {
		String parentName = getParent() == null ? "无" : getParent().getName();
		String blank = StringUtils.repeat("	", cent - 1);
		return  blank + "\"" + getName() + "\"" + ": " + "{" + "\n"
				+ blank + "	" + "\"" + "类型" + "\"" + ": " + "\"" + "个人" + "\"" + "," + "\n"
				+ blank + "	" + "\"" + "父亲" + "\"" + ": " + "\"" + parentName + "\"" + "\n"
				+ blank + "}" + "\n";
	}




}